package com.smartrm.globalinfrcore.cmd.interceptor;

import com.smartrm.globalinfrcore.cmd.AbstractCommandContext;
import com.smartrm.globalinfrcore.cmd.Command;
import com.smartrm.globalinfrcore.cmd.CommandConfig;

/*
 * @program: common-starters
 * @description: 命令拦截器：构造一条执行链：
 *                      interceptor_one ----> interceptor_two --->  interceptor_three --|
 *                                 <---                       <---
 *
 * @author: houhong
 * @create: 2023-01-11 21:29
 */
public interface CommandInterceptor {
    /*
     * 获取下一个命令拦截器
     */
    CommandInterceptor getNext();

    /*
     * 设置下一个拦截器
     */
    void setNext(CommandInterceptor next);

    /*
     * 真正执行命令
     */
    <T> T execute(AbstractCommandContext commandContext,CommandConfig config, Command<T> command) throws Exception;

}